<template>
	<view class="goods-detail" @click="onJump">
		<view class="picture">
			<u--image :src="item.productImage" width="150rpx" height="150rpx" mode="aspectFit" radius="6">
			</u--image>
		</view>
		<view class="detail">
			<u-text :text="item.productName" lineHeight="20" :lines="2"></u-text>
			<view class="skuName" v-if="item.skuNames">{{ item.skuNames }}</view>
		</view>
		<view class="price">
			<view class="money">
				￥
				<text class="showPrice">{{ getPrice(item.price, 1) }}</text>
				.{{ getPrice(item.price, 2) }}
			</view>
			<view class="number">x {{item.quantity}}</view>
			<view class="subtotal">
				小计：￥ {{ item.refundSubtotal }}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'afterSale-goods-item',
		props: {
			item: {
				type: Object,
				default () {
					return {}
				}
			},
			customStyles: {
				type: Object,
				default () {
					return {}
				}
			},
			borderBottom: {
				type: Boolean,
				default: true
			},
			url: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
			};
		},
		methods:{
			// 页面跳转
			onJump() {
				if (this.url) {
					uni.navigateTo({
						url: this.url
					})
				}
			},
			// 得到显示的金额
			getPrice(price, type) {
				let valMoney = price.toString().split(".");
				let decimals = "00";
				let showPrice = "0";
				if(valMoney.length == 2){
					showPrice = valMoney[0];
					if(valMoney[1].length == 1){
						decimals = valMoney[1] + "0"
					}else{
						decimals = valMoney[1];
					}
				}else{
					showPrice = valMoney[0];
				}
				if (type == 1) {
					return showPrice
				} else {
					return decimals
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goods-detail {
		display: flex;
		align-items: center;
		position: relative;
		margin-bottom: 40rpx;

		.detail {
			flex: 1;
			margin: 0 20rpx;

			.skuName {
				color: #AAAAAA;
				font-size: 22rpx;
				margin-top: 15rpx;
			}
		}

		.price {
			text-align: right;

			.money {
				font-size: 22rpx;

				.showPrice {
					font-size: 30rpx;
				}
			}

			.number {
				color: #999999;
				font-size: 24rpx;
				margin: 20rpx 0;
			}
			
			.subtotal{
				font-size: 24rpx;
				color: #999999;
			}
		}
	}
</style>
